home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / 83win / data1.cab / DLL_Toolkit / Source / HTBfileopen / HTBfileopen.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-02  |  3.0 KB  |  103 lines

  1. #include "stdafx.h"
  2. #include "HTBfileopen.h"
  3. #include "export.h"
  4.  
  5. #ifdef _DEBUG
  6. #define new DEBUG_NEW
  7. #undef THIS_FILE
  8. static char THIS_FILE[] = __FILE__;
  9. #endif
  10.  
  11. BEGIN_MESSAGE_MAP(CHTBfileopenApp, CWinApp)
  12.     //{{AFX_MSG_MAP(CHTBfileopenApp)
  13.         // NOTE - the ClassWizard will add and remove mapping macros here.
  14.         //    DO NOT EDIT what you see in these blocks of generated code!
  15.     //}}AFX_MSG_MAP
  16. END_MESSAGE_MAP()
  17.  
  18. CHTBfileopenApp::CHTBfileopenApp()
  19. {
  20. }
  21.  
  22. CHTBfileopenApp theApp;
  23.  
  24. void Fileopen(void *RetBuffer, char * FoRetVal, char * foP1, char * foP2, char * foP3, long foP4) 
  25. {
  26.     AFX_MANAGE_STATE(AfxGetStaticModuleState());
  27.  
  28.     DWORD dwFlags;        //Flag to define Dialog Box style and appearence.    
  29.     dwFlags = foP4;
  30.  
  31.         
  32.     BOOL     bOpenFileDialog    = TRUE;                        
  33.     LPCTSTR  lpszDefExt            = foP1;                    //The default filename extension. 
  34.     LPCTSTR     lpszFileName        = foP2;                    //The initial filename that appears in the filename edit box. 
  35.     LPCTSTR  lpszFilter            = foP3;                    //file extension filters.
  36.     
  37.     CWnd* pParentWnd;
  38.     pParentWnd = CWnd::FromHandle(g_hBasicWindow);
  39.     pParentWnd = pParentWnd->GetTopWindow();
  40.  
  41.     CString     FoReturnString;
  42.         
  43.     CFileDialog FileOpener(bOpenFileDialog,                //CFileDialog assignment. 
  44.                     lpszDefExt, 
  45.                     lpszFileName, 
  46.                     dwFlags, 
  47.                     lpszFilter, 
  48.                     pParentWnd);
  49.  
  50.     FileOpener.m_ofn.hwndOwner = g_hBasicWindow;
  51.     
  52.     
  53.     FileOpener.DoModal();                                //call the assignment.
  54.  
  55.     if(OFN_ALLOWMULTISELECT & dwFlags)                            //if the multiselect flag is set then
  56.     {                                                            //put all the names into the HTB buffer
  57.         POSITION pos;
  58.         pos = FileOpener.GetStartPosition();
  59.         while(pos)
  60.         {
  61.             FoReturnString = FileOpener.GetNextPathName(pos);            //get the string.
  62.             strcpy(FoRetVal, FoReturnString);                    //copy the string to FoRetVal.
  63.             PutBuffer(RetBuffer,FoRetVal,1);                    //put the string in the HTB buffer
  64.         }
  65.     }
  66.     else
  67.     {
  68.         FoReturnString = FileOpener.GetPathName();            //get the string.
  69.         strcpy(FoRetVal, FoReturnString);                    //copy the string to FoRetVal.
  70.         PutBuffer(RetBuffer,FoRetVal,1);                    //put the string in the HTB buffer
  71.     }
  72. }
  73.  
  74. void Saveas(char * SaRetVal, char * SaP1, char * SaP2, char * SaP3, long SaP4) 
  75. {
  76.     
  77.     DWORD dwFlags;                    //Flag to define Dialog Box style and appearence.    
  78.     dwFlags = SaP4;
  79.     
  80.     
  81.     BOOL     bSaveAsDialog        = FALSE;                        
  82.     LPCTSTR  lpszDefExt            = SaP1;                    //The default filename extension.
  83.     LPCTSTR     lpszFileName        = SaP2;                    //The initial filename that appears in the filename edit box.    
  84.     LPCTSTR  lpszFilter            = SaP3;                    //file extension filters.
  85.     
  86.     CWnd* pParentWnd;
  87.     pParentWnd = CWnd::FromHandle(g_hBasicWindow);
  88.     pParentWnd = pParentWnd->GetTopWindow();
  89.  
  90.     CString     SaReturnString;    
  91.  
  92.     CFileDialog SaveAsFunc(bSaveAsDialog,                //CFileDialog assignment.
  93.                     lpszDefExt, 
  94.                     lpszFileName, 
  95.                     dwFlags, 
  96.                     lpszFilter, 
  97.                     pParentWnd);
  98.  
  99.     SaveAsFunc.DoModal();                                //call the assignment.
  100.     SaReturnString = SaveAsFunc.GetPathName();            //get the string.
  101.     strcpy(SaRetVal, SaReturnString);                    //copy the string to SaRetVal.
  102. }
  103.